<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

if (sizeof($pages)>0) {
	$allpages = $this->db->select('parent_title, parent_id, parent_curl')->from('catalog_parents')->get()->result_array();
	foreach ($allpages as $allpages_one) {
		$book[$allpages_one['parent_id']] = array('title' => $allpages_one['parent_title'], 'id' => $allpages_one['parent_id'], 'curl' => $allpages_one['parent_curl']);
	}
	echo "<ul>";
	foreach ($pages as $page) {
			$cr = explode("&", $page['parent_path']);
			$crumps = "";
			$k = 0;
			foreach ($cr as $cr_one) {
				preg_match_all('#:[0-9]+:#', $cr_one, $num);
				$num = intval(str_replace(":", "", $num[0][0]));
				if ($k==1) $frst = $book[$num]['curl'];
				if ($num != "0")
				$parent_link = ($frst && $frst != $book[$num]['curl']?"/".$frst:"")."/".$book[$num]['curl'].".html";
				$k++;
			}
		echo "<li>";
			echo "<a href='".$parent_link."'>".$page['parent_title']."</a>";
			if (is_array($page['items'])) {
				echo "<ul>";
					foreach ($page['items'] as $item) {
						$item_link = $this->catalog_service_model->get_item_link($item['item_id']);
						echo "<li><a href='".$item_link."'>".$item['item_title']."</a></li>";
					}
				echo "</ul>";
			}
			if (is_array($page['childs'])) {
				$data['pages'] = $page['childs'];
				$this->load->view('modules/articles/map2', $data);
			}
		echo "</li>";
	}
	echo "</ul>";
}
?>